﻿#region Using Statements
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using System.Collections.Generic;
#endregion

namespace BubbleSurvival
{

    public class InputState
    {
        #region Fields

        public KeyboardState CurrentKeyboardState;
        public KeyboardState LastKeyboardState;

        public MouseState CurrentMouseState;
        public MouseState LastMouseState;

        #endregion

        #region Initialization

        public InputState()
        {
            CurrentKeyboardState = new KeyboardState();
            LastKeyboardState = new KeyboardState();

            CurrentMouseState = new MouseState();
            LastMouseState = new MouseState();
        }


        #endregion

        #region Public Methods

        public void Update()
        {

            LastKeyboardState = CurrentKeyboardState;
            CurrentKeyboardState = Keyboard.GetState();

            LastMouseState = CurrentMouseState;
            CurrentMouseState = Mouse.GetState();

        }

        public bool IsNewKeyPress(Keys key)
        {
            return (CurrentKeyboardState.IsKeyDown(key) &&
                    LastKeyboardState.IsKeyUp(key));
        }


        public bool IsMenuSelect()
        {
            return IsNewKeyPress(Keys.Space) || IsNewKeyPress(Keys.Enter);
        }

        public bool IsMenuCancel()
        {
            return IsNewKeyPress(Keys.Escape);
        }


        public bool IsMenuUp()
        {
            return IsNewKeyPress(Keys.Up);
        }

        public bool IsMenuDown()
        {
            return IsNewKeyPress(Keys.Down);
        }

        public bool IsMenuLeft()
        {
            return IsNewKeyPress(Keys.Left);
        }

        public bool IsMenuRight()
        {
            return IsNewKeyPress(Keys.Right);
        }

        public bool IsPauseGame()
        {

            return IsNewKeyPress(Keys.Escape);
        }

        #endregion
    }
}
